\(\int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx\) [105]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 24, antiderivative size = 82 \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\frac {3 x}{8 a}-\frac {i}{8 d (a-i a \tan (c+d x))}+\frac {i a}{8 d (a+i a \tan (c+d x))^2}+\frac {i}{4 d (a+i a \tan (c+d x))} \]

[Out]

3/8*x/a-1/8*I/d/(a-I*a*tan(d*x+c))+1/8*I*a/d/(a+I*a*tan(d*x+c))^2+1/4*I/d/(a+I*a*tan(d*x+c))

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 82, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.125, Rules used = {3568, 46, 212} \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\frac {i a}{8 d (a+i a \tan (c+d x))^2}-\frac {i}{8 d (a-i a \tan (c+d x))}+\frac {i}{4 d (a+i a \tan (c+d x))}+\frac {3 x}{8 a} \]

[In]

Int[Cos[c + d*x]^2/(a + I*a*Tan[c + d*x]),x]

[Out]

(3*x)/(8*a) - (I/8)/(d*(a - I*a*Tan[c + d*x])) + ((I/8)*a)/(d*(a + I*a*Tan[c + d*x])^2) + (I/4)/(d*(a + I*a*Ta
n[c + d*x]))

Rule 46

Int[((a_) + (b_.)*(x_))^(m_)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d*x
)^n, x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && ILtQ[m, 0] && IntegerQ[n] &&  !(IGtQ[n, 0] && Lt
Q[m + n + 2, 0])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3568

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[1/(a^(m - 2)*b
*f), Subst[Int[(a - x)^(m/2 - 1)*(a + x)^(n + m/2 - 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x
] && EqQ[a^2 + b^2, 0] && IntegerQ[m/2]

Rubi steps \begin{align*} \text {integral}& = -\frac {\left (i a^3\right ) \text {Subst}\left (\int \frac {1}{(a-x)^2 (a+x)^3} \, dx,x,i a \tan (c+d x)\right )}{d} \\ & = -\frac {\left (i a^3\right ) \text {Subst}\left (\int \left (\frac {1}{8 a^3 (a-x)^2}+\frac {1}{4 a^2 (a+x)^3}+\frac {1}{4 a^3 (a+x)^2}+\frac {3}{8 a^3 \left (a^2-x^2\right )}\right ) \, dx,x,i a \tan (c+d x)\right )}{d} \\ & = -\frac {i}{8 d (a-i a \tan (c+d x))}+\frac {i a}{8 d (a+i a \tan (c+d x))^2}+\frac {i}{4 d (a+i a \tan (c+d x))}-\frac {(3 i) \text {Subst}\left (\int \frac {1}{a^2-x^2} \, dx,x,i a \tan (c+d x)\right )}{8 d} \\ & = \frac {3 x}{8 a}-\frac {i}{8 d (a-i a \tan (c+d x))}+\frac {i a}{8 d (a+i a \tan (c+d x))^2}+\frac {i}{4 d (a+i a \tan (c+d x))} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.18 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.06 \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\frac {2-3 i \tan (c+d x)+3 \tan ^2(c+d x)+3 \arctan (\tan (c+d x)) (-i+\tan (c+d x))^2 (i+\tan (c+d x))}{8 a d (-i+\tan (c+d x))^2 (i+\tan (c+d x))} \]

[In]

Integrate[Cos[c + d*x]^2/(a + I*a*Tan[c + d*x]),x]

[Out]

(2 - (3*I)*Tan[c + d*x] + 3*Tan[c + d*x]^2 + 3*ArcTan[Tan[c + d*x]]*(-I + Tan[c + d*x])^2*(I + Tan[c + d*x]))/
(8*a*d*(-I + Tan[c + d*x])^2*(I + Tan[c + d*x]))

Maple [A] (verified)

Time = 0.94 (sec) , antiderivative size = 61, normalized size of antiderivative = 0.74

method result size
risch \(\frac {3 x}{8 a}+\frac {i {\mathrm e}^{-4 i \left (d x +c \right )}}{32 a d}+\frac {i \cos \left (2 d x +2 c \right )}{8 a d}+\frac {\sin \left (2 d x +2 c \right )}{4 a d}\) \(61\)
derivativedivides \(\frac {-\frac {3 i \ln \left (\tan \left (d x +c \right )-i\right )}{16}-\frac {i}{8 \left (\tan \left (d x +c \right )-i\right )^{2}}+\frac {1}{4 \tan \left (d x +c \right )-4 i}+\frac {3 i \ln \left (\tan \left (d x +c \right )+i\right )}{16}+\frac {1}{8 \tan \left (d x +c \right )+8 i}}{d a}\) \(75\)
default \(\frac {-\frac {3 i \ln \left (\tan \left (d x +c \right )-i\right )}{16}-\frac {i}{8 \left (\tan \left (d x +c \right )-i\right )^{2}}+\frac {1}{4 \tan \left (d x +c \right )-4 i}+\frac {3 i \ln \left (\tan \left (d x +c \right )+i\right )}{16}+\frac {1}{8 \tan \left (d x +c \right )+8 i}}{d a}\) \(75\)

[In]

int(cos(d*x+c)^2/(a+I*a*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

3/8*x/a+1/32*I/a/d*exp(-4*I*(d*x+c))+1/8*I/a/d*cos(2*d*x+2*c)+1/4/a/d*sin(2*d*x+2*c)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 54, normalized size of antiderivative = 0.66 \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\frac {{\left (12 \, d x e^{\left (4 i \, d x + 4 i \, c\right )} - 2 i \, e^{\left (6 i \, d x + 6 i \, c\right )} + 6 i \, e^{\left (2 i \, d x + 2 i \, c\right )} + i\right )} e^{\left (-4 i \, d x - 4 i \, c\right )}}{32 \, a d} \]

[In]

integrate(cos(d*x+c)^2/(a+I*a*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/32*(12*d*x*e^(4*I*d*x + 4*I*c) - 2*I*e^(6*I*d*x + 6*I*c) + 6*I*e^(2*I*d*x + 2*I*c) + I)*e^(-4*I*d*x - 4*I*c)
/(a*d)

Sympy [A] (verification not implemented)

Time = 0.17 (sec) , antiderivative size = 151, normalized size of antiderivative = 1.84 \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\begin {cases} \frac {\left (- 512 i a^{2} d^{2} e^{8 i c} e^{2 i d x} + 1536 i a^{2} d^{2} e^{4 i c} e^{- 2 i d x} + 256 i a^{2} d^{2} e^{2 i c} e^{- 4 i d x}\right ) e^{- 6 i c}}{8192 a^{3} d^{3}} & \text {for}\: a^{3} d^{3} e^{6 i c} \neq 0 \\x \left (\frac {\left (e^{6 i c} + 3 e^{4 i c} + 3 e^{2 i c} + 1\right ) e^{- 4 i c}}{8 a} - \frac {3}{8 a}\right ) & \text {otherwise} \end {cases} + \frac {3 x}{8 a} \]

[In]

integrate(cos(d*x+c)**2/(a+I*a*tan(d*x+c)),x)

[Out]

Piecewise(((-512*I*a**2*d**2*exp(8*I*c)*exp(2*I*d*x) + 1536*I*a**2*d**2*exp(4*I*c)*exp(-2*I*d*x) + 256*I*a**2*
d**2*exp(2*I*c)*exp(-4*I*d*x))*exp(-6*I*c)/(8192*a**3*d**3), Ne(a**3*d**3*exp(6*I*c), 0)), (x*((exp(6*I*c) + 3
*exp(4*I*c) + 3*exp(2*I*c) + 1)*exp(-4*I*c)/(8*a) - 3/(8*a)), True)) + 3*x/(8*a)

Maxima [F(-2)]

Exception generated. \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate(cos(d*x+c)^2/(a+I*a*tan(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.37 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.16 \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=-\frac {-\frac {6 i \, \log \left (\tan \left (d x + c\right ) + i\right )}{a} + \frac {6 i \, \log \left (\tan \left (d x + c\right ) - i\right )}{a} + \frac {2 \, {\left (3 \, \tan \left (d x + c\right ) + 5 i\right )}}{a {\left (-i \, \tan \left (d x + c\right ) + 1\right )}} + \frac {-9 i \, \tan \left (d x + c\right )^{2} - 26 \, \tan \left (d x + c\right ) + 21 i}{a {\left (\tan \left (d x + c\right ) - i\right )}^{2}}}{32 \, d} \]

[In]

integrate(cos(d*x+c)^2/(a+I*a*tan(d*x+c)),x, algorithm="giac")

[Out]

-1/32*(-6*I*log(tan(d*x + c) + I)/a + 6*I*log(tan(d*x + c) - I)/a + 2*(3*tan(d*x + c) + 5*I)/(a*(-I*tan(d*x +
c) + 1)) + (-9*I*tan(d*x + c)^2 - 26*tan(d*x + c) + 21*I)/(a*(tan(d*x + c) - I)^2))/d

Mupad [B] (verification not implemented)

Time = 4.05 (sec) , antiderivative size = 60, normalized size of antiderivative = 0.73 \[ \int \frac {\cos ^2(c+d x)}{a+i a \tan (c+d x)} \, dx=\frac {3\,x}{8\,a}-\frac {\frac {3\,{\mathrm {tan}\left (c+d\,x\right )}^2}{8}-\frac {\mathrm {tan}\left (c+d\,x\right )\,3{}\mathrm {i}}{8}+\frac {1}{4}}{a\,d\,{\left (1+\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^2\,\left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )} \]

[In]

int(cos(c + d*x)^2/(a + a*tan(c + d*x)*1i),x)

[Out]

(3*x)/(8*a) - ((3*tan(c + d*x)^2)/8 - (tan(c + d*x)*3i)/8 + 1/4)/(a*d*(tan(c + d*x)*1i + 1)^2*(tan(c + d*x) +
1i))